<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Holiday_Model extends CI_Model {
	
	private $table= 'holidays';
	private $shiftingModel;
	private $clientModel;
	function __construct() {
		parent::__construct();
		$this->shiftingModel = $this->load->model('Shifting_Model');
		$this->clientModel = $this->load->model('Client_Model');
	}
	
	function getDay($date){
		$this->db->select("h.*, ht.type_name, ht.percent, ht.excess_percent");
		$this->db->from($this->table .' as h');
		$this->db->join('holiday_type as ht','ht.id=h.holiday_type','left');
		//$this->db->where($date. ' IN (h.date_start, h.date_end) ');
		$this->db->where('h.date_start >=', $date);
		$this->db->where('h.date_end <=', $date);
		$query = $this->db->get();
		return $query->result();
	}

	public function getObject($table, $filter=array()){
		$query = $this->db->get_where($this->table,$filter,1,0);
		$result = $query->result();
		if(!empty($result)){
			return (!empty($filter))?$result[0]:$result;
		} else {
			return false;
		}
	}
	
	
	
}